$(function () {
  var rexiao = document.querySelector(".rexiao");
  var str1 = "";
  // console.log(data1[0].data1);
  data1[0].data1.forEach(function (v, i) {
    str1 += `
        <li>
            <div class="tp">
                <img src=${v.src} alt="">
            </div>
            <div class="one">${v.introduce}</div>
            <div class="two">${v.price}</div>
         </li> 
`;
  });
  rexiao.innerHTML += str1;
  //
  //
  //
  var cuxiao = document.querySelector(".cuxiao");
  var str2 = "";
  data12[0].data1.forEach(function (v, i) {
    str2 += `
        <li>
            <div class="tp">
                <img src=${v.src} alt="">
            </div>
            <div class="one">${v.introduce}</div>
            <div class="two">${v.price}</div>
         </li>
`;
  });
  cuxiao.innerHTML += str2;
  //
  //
  //
  var tj = document.querySelector(".tj");
  var str3 = "";
  // console.log(allObj.presellData);
  allObj.presellData.forEach(function (v, i) {
    str3 += `
  <li class="itemdata" data-id ="${v.id}">
  <img src=${v.data.src} alt="">
  <div>${v.data.name}</div>
  <span>¥${v.data.new}.00</span>
</li>
`;
  });

  tj.innerHTML += str3;
  let lis = $(".itemdata");
  console.log(lis);
  lis.click(function () {
    let id = $(this).attr("data-id");
    window.localStorage.setItem("id" + id + "", id);
    window.localStorage.setItem("id", id);
    // window.localStorage.setItem("sid", id);
    window.localStorage.setItem("index", 4);
    window.location.href = "particulars.html";
  });

  //
  //
  //
  var tjj = document.querySelector(".tjj");
  var str4 = "";
  data3[0].data3.forEach(function (v, i) {
    str4 += `
  <li>
  <img src=${v.src} alt="">
  <div>${v.introduce}</div>
  <span>${v.price}</span>
</li>
`;
  });
  tjj.innerHTML += str4;
  //
  //
  //
  var liuljia = document.querySelector(".liuljia");
  var str5 = "";
  data4[0].data4.forEach(function (v, i) {
    str5 += `
  <li>
  <img src=${v.src}  alt="">
  <p>${v.price}</p>
  <div class="zzi">${v.introduce}</div>
  <div class="xiangq">查看详情</div>
</li>
`;
  });
  liuljia.innerHTML += str5;
  //
  //
  //

  var rxh = document.querySelector(".rxh");
  var cxh = document.querySelector(".cxh");
  rxh.onmouseover = function () {
    rxh.style.color = "red";
    cxh.style.color = "black";
    rexiao.style.opacity = "1";
    cuxiao.style.opacity = "0";
  };
  cxh.onmouseover = function () {
    cxh.style.color = "red";
    rxh.style.color = "black";
    rexiao.style.opacity = "0";
    cuxiao.style.opacity = "1";
  };
  //
  //
  //

  var index = 2;
  $(".xiangzuo").on("click", function () {
    index++;
    if (index % 2 == 1) {
      $(".lunbo").animate({
        left: -1110,
      });
    } else {
      $(".lunbo").animate({
        left: 0,
      });
    }
  });
  $(".xiangyou").on("click", function () {
    index++;
    if (index % 2 == 0) {
      $(".lunbo").animate({
        left: 0,
      });
    } else {
      $(".lunbo").animate({
        left: -1110,
      });
    }
  });
});
//
//
//
var shangqu = document.querySelector(".shangqu");
var louc = document.querySelector(".louc");
var pitems = document.querySelectorAll(".pitems");
var dad = document.querySelectorAll(".dad");

shangqu.onclick = function () {
  // window.scroll(0, 0);
  window.scrollTo({
    top: 0,
    behavior: "smooth",
  });
};
pitems[0].onclick = function () {
  window.scrollTo({
    top: 400,
    behavior: "smooth",
  });
};
pitems[1].onclick = function () {
  window.scrollTo({
    top: 1000,
    behavior: "smooth",
  });
};
pitems[2].onclick = function () {
  window.scrollTo({
    top: 1700,
    behavior: "smooth",
  });
};
pitems[3].onclick = function () {
  window.scrollTo({
    top: 2200,
    behavior: "smooth",
  });
};
var hei = document.querySelector(".hei");
window.onscroll = function (e) {
  var winhei = window.pageYOffset;
  if (winhei >= 400) {
    louc.style.height = "240px";
  } else {
    louc.style.height = "0px";
  }
  if (winhei >= 400 && winhei <= 900) {
    pitems[0].style.backgroundColor = "red";
  } else {
    pitems[0].style.backgroundColor = "#a3a0a1";
  }
  if (winhei >= 1000 && winhei <= 1400) {
    pitems[1].style.backgroundColor = "red";
  } else {
    pitems[1].style.backgroundColor = "#a3a0a1";
  }
  if (winhei >= 1500 && winhei <= 1900) {
    pitems[2].style.backgroundColor = "red";
  } else {
    pitems[2].style.backgroundColor = "#a3a0a1";
  }
  if (winhei >= 1900 && winhei <= 2450) {
    pitems[3].style.backgroundColor = "red";
  } else {
    pitems[3].style.backgroundColor = "#a3a0a1";
  }
  if (winhei >= 30) {
    hei.style.height = "0px";
  } else {
    hei.style.height = "30px";
  }
};
dad.forEach(function (v, i) {
  v.style.backgroundColor = "red";
});
